package com.linshuo.employee.service.impl;

import com.linshuo.employee.entity.Position;
import com.linshuo.employee.repository.PositionRepository;
import com.linshuo.employee.service.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class PositionServiceImpl implements PositionService {
    @Autowired
    private PositionRepository positionRepository;

    @Override
    public Position savePosition(Position position) {
        return positionRepository.save(position);
    }

    @Override
    public Position updatePosition(Position position) {
        return positionRepository.save(position);
    }

    @Override
    public void deletePosition(Long id) {
        positionRepository.deleteById(id);
    }

    @Override
    public Position getPositionById(Long id) {
        Optional<Position> position = positionRepository.findById(id);
        return position.orElse(null);
    }

    @Override
    public List<Position> getAllPositions() {
        return positionRepository.findAll();
    }
} 